package com.kasax.test.bc.ui.fragment

import android.view.View
import com.kasax.base.BasicBindingFragment
import com.kasax.test.bc.R
import com.kasax.test.bc.databinding.FragmentOpenSdkComponentTestBinding
import com.kasax.test.bc.viewmodel.OpenSDKNetworkComponentTestViewModel


/**
 * 开源库测试组件
 */
class OpenSDKComponentTestFragment : BasicBindingFragment<FragmentOpenSdkComponentTestBinding>() {
    val moedel by lazy { OpenSDKNetworkComponentTestViewModel() }

    override fun getLayoutId(): Int = R.layout.fragment_open_sdk_component_test

    override fun addListeners(view: View) {
        testWithOkHttpClient()
        testWithRetrofit()
    }

    private fun testWithRetrofit() {
        viewBinding.btnGetipaddrTestWithRetrofit.setOnClickListener {
            moedel.testGetIpAddrWithRetrofit()
        }
        viewBinding.btnGettaobaipTestWithRetrofit.setOnClickListener {
            moedel.getToabaiIpWithRetrofit()
        }
        viewBinding.btnFromurlTestWithRetrofit.setOnClickListener {
            moedel.getFormUrlWithRetrofit()
        }
        viewBinding.btnJsonParamTestWithRetrofit.setOnClickListener {
            moedel.getJsonParamWithRetrofit()
        }
        viewBinding.btnXmlParamTestWithRetrofit.setOnClickListener {
            moedel.getXmlParamWithRetrofit()
        }
        viewBinding.btnGetbannersWithWanandroidapiTestWithRetrofit.setOnClickListener {
            moedel.testWanAndroidBannersWithRetrofit()
        }
        viewBinding.btnLoginWithWanandroidapiTestWithRetrofit.setOnClickListener {
            moedel.testWanAndroidLoginWithRetrofit()
        }
    }

    private fun testWithOkHttpClient() {
        viewBinding.btnGetipaddrTestWithOkhttpclent.setOnClickListener {
            moedel.testGetIpAddrWithOKHttpClient()
        }
        viewBinding.btnGettaobaipTestWithOkhttpclent.setOnClickListener {
            moedel.getToabaiIpWithOKHttpClient()
        }
        viewBinding.btnFromurlTestWithOkhttpclent.setOnClickListener {
            moedel.getFormUrlWithOKHttpClient()
        }
        viewBinding.btnJsonParamTestWithOkhttpclent.setOnClickListener {
            moedel.getJsonParamWithOKHttpClient()
        }
        viewBinding.btnXmlParamTestWithOkhttpclent.setOnClickListener {
            moedel.getXmlParamWithOKHttpClient()
        }
        viewBinding.btnGetbannersWithWanandroidapiTestWithOkhttpclent.setOnClickListener {
            moedel.testWanAndroidBannersWithOKHttpClient()
        }
        viewBinding.btnLoginWithWanandroidapiTestWithOkhttpclent.setOnClickListener {
            moedel.testWanAndroidLoginWithOKHttpClient()
        }
    }


}